package com.fzy.common.ftp;

public class ShellUtil {
    private ShellUtil() {
    }

    public static void shell(String sh) {
        try {
            String p = System.getProperty("os.name");
            // System.out.println("os: " +p);
            if (p.toUpperCase().startsWith("WINDOWS")) {
                return;
            } else {
                System.out.println("shell:" + sh);
                Process process = Runtime.getRuntime().exec(sh);
                process.waitFor();
                // System.out.println(process.getOutputStream().toString());
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public static void main(String[] args) {
        ShellUtil.shell("service sshd stop\n");
        ShellUtil.shell("service sshd start\n");
    }

}
